package com.springcloud.alibabanacosconfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class AlibabaNacosConfigApplication {
	public static void main(String[] args) {
		SpringApplication.run(AlibabaNacosConfigApplication.class, args);
	}
	@Slf4j
	@RestController
	@RefreshScope
	static class TestController{
		@Value("${juzspace.title:}")
		private String title;

		@Value("${spring.rabbitmq.host}")
		private String rabbitmqHost;

		@Autowired
		private Environment env;


		@GetMapping("/test")
		@ResponseBody
		public String hello(){
			String username = env.getProperty("log.user.queue.name");
			log.info("usernamemq:{}",username);
			return title+rabbitmqHost;
		}

		@Value(value = "${user.name:}")
		 String userName;
		@Value("${user.age:}")
		 String age;

		@GetMapping("/test2")
		public String test2() {
			return title + ", " + userName + ", " + age;
		}
	}
}
